<template>
	<view class="swiper-container">
		<swiper :autoplay="true" :circular="true" :interval="3000" :duration="500" :current="swiperCur"
			:indicator-dots="true" @change="swiperChange">
			<block v-for="(item, index) in dataConfig.swiperConfig.list" :key="index">
				<swiper-item :class="{ active: index == swiperCur }">
					<!-- <view @click="goDetail(item._id)" class="slide-navigator acea-row row-between-wrapper">
						<image :src="item.img" mode="aspectFill" class="img" ></image>
					</view> -->
					<view @click="goDetail(item.info[1].value)" class="slide-navigator acea-row row-between-wrapper">
						<image :src="item.img" mode="aspectFill" class="img"></image>
					</view>
				</swiper-item>
			</block>
		</swiper>
		<MyUseOut :showModal="isUseOut" @close="isUseOut=false" />
	</view>
</template>

<script>
	export default {
		name: "MyAdvertise",
		data() {
			return {
				swiperCur: 0,
				isUseOut: false,
			};
		},
		props: {
			data: {
				type: Array,
				default: () => []
			},
			dataConfig: {
				type: Object,
				default: () => {}
			},
		},
		onLoad() {
			// 如果是从本页面的MyUseOut弹框进入三种增加次数的页面去了，并且成功后，再跳转到本页面要默认关闭弹窗
			uni.$on('closeModal', data => {
				this.isUseOut = data
			})
		},
		methods: {
			swiperChange(e) {
				let {
					current,
					source
				} = e.detail;
				if (source === "autoplay" || source === "touch") {
					this.swiperCur = e.detail.current;
				}
			},
			goDetail(url) {
				// 跳转第三方链接
				if (url[0] == 'h') {
					window.open(url)
				} else {
					if (!uni.getStorageSync('infinite')) {
						this.isUseOut = true
						return
					}
					// 跳转本地视频
					uni.navigateTo({
						url: url
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.swiper-container {
		margin: 20rpx 0;
		width: 100%;

		.swiper-item {
			border-radius: 15rpx;
		}

		.acea-row {
			border-radius: 15rpx;
			height: 100%;
		}

		.img {
			width: 100%;
			height: 100%;
			border-radius: 15rpx;
		}
	}
</style>